package com.zhaoyue.study.jdk;

import com.google.common.collect.Lists;

import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 2017/2/24
 * Time: 14:30
 * To change this template use File | Settings | File Templates.
 */
public class ListStudy {


    public  static final int hash(Object k) {
        int h = 0;
        if (0 != h && k instanceof String) {
            return sun.misc.Hashing.stringHash32((String) k);
        }

        h ^= k.hashCode();

        // This function ensures that hashCodes that differ only by
        // constant multiples at each bit position have a bounded
        // number of collisions (approximately 8 at default load factor).
        h ^= (h >>> 20) ^ (h >>> 12);
        return h ^ (h >>> 7) ^ (h >>> 4);
    }

    public static void main(String[] args) {

        List list = new ArrayList();
        list.add("1");
        list.get(0);
        list.size();
        list.contains(1);

        LinkedList linkedList = new LinkedList();
        linkedList.add("2");
        linkedList.get(0);
        linkedList.size();

        System.out.println("-----------------");
        List list1 = new ArrayList(0);
        list1.add("aa");
        System.out.println(list1.get(0));


        List list2 = new ArrayList(20);
        list2.add("bb");
        System.out.println(list2.get(0));

        Map map = new HashMap();
        map.put("aa",1);


        System.out.println((4 & 15));
        System.out.println((20 & 15));
        System.out.println();

        List list5 =  Collections.synchronizedList(new ArrayList<>());

        char ch = '好';

        int i = 'a';
        System.out.println(i);
        System.out.println(ch);

        byte b = (byte)'中';
        System.out.println(b);

        System.out.println(ListStudy.hash(new Test()));
        System.out.println(new Test().hashCode());




    }
}
